/*************************************************************************
 * File Name:    Unique_Binary_Search_Trees.cc
 * Author:       zero91
 * Mail:         jianzhang9102@gmail.com
 * Created Time: Sat 02 Nov 2013 04:39:23 PM CST
 * 
 * Description:  
 |------------------------------------------------------------------------
 | Unique Binary Search Trees
 | Given n, how many structurally unique BST's (binary search trees) that
 | store values 1...n?
 |
 | For example,
 | Given n = 3, there are a total of 5 unique BST's.
 |
 |    1         3     3      2      1
 |     \       /     /      / \      \
 |      3     2     1      1   3      2
 |     /     /       \                 \
 |    2     1         2                 3
 |-----------------------------------------------------------------------
 ************************************************************************/

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <iomanip>

using namespace std;

class Solution {
    /* Catalan Number */
public:
    int numTrees(int n) {
        long long ans = 1;
        for (int i = n + 2; i <= 2 * n; ++i) {
            ans *= i;
        }
        for (int i = 1; i <= n; ++i) ans /= i;
        
        return ans;
    }
};
